package com.demo.morning;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static java.util.concurrent.Executors.*;

/**
 * @ClassName 线程池例子
 * @Description TODO
 * @Author tianqinglong
 * @Date 11:12 2022/7/13
 * @Version 1.0
 **/
public class 线程池例子 {
    public static void main(String[] args) {
        test();

    }

    private static void test() {
        ExecutorService pool = Executors.newFixedThreadPool(2);
        pool.submit(()->{
            System.out.println(Thread.currentThread().getName()+"---1");
        });
        pool.submit(()->{
            System.out.println(Thread.currentThread().getName()+"---2");
        });
        pool.submit(()->{
            System.out.println(Thread.currentThread().getName()+"---3");
        });pool.submit(()->{
            System.out.println(Thread.currentThread().getName()+"---4");
        });

    }
}
